import { Injectable, NestMiddleware } from '@nestjs/common';
import { Request, Response,} from 'express';
import { AppService } from './app.service';

@Injectable()
export class AaaMiddleware implements NestMiddleware {
  
  //注入AppService
   constructor(private readonly appService: AppService){}


  //因为这时候并不知道你用的 express 还是 fastify
  //所以 request、response 是 any，手动标注下类型就好了

  use(req: Request, res: Response, next: () => void) {
    console.log('before');
    //console.log('------'+this.appService.getHello());
    next();    //表示调用下一个 middleware  |  @Next nest nest()是调用下一个同名的handler 
    console.log('after');
  }
}